import cv2
import numpy as np 
import os 
path1=r'D:\pathology\train_data\train'
path2=r'D:\pathology\train_data\trainmask'
path3=r'D:\pathology\train_data\mask1'
def get_point(path1):
    im=cv2.imread(path1,0)
    point=[]
    for i in range(im.shape[0]):
        for j in range(im.shape[1]):
            if im[i,j]==255:
                # print([i,j])
                point.append([i,j])
    return point
for i in os.listdir(path2):
    i1=os.path.join(path1,i)
    i2=os.path.join(path2,i)
    i3=os.path.join(path3,i)
    points=get_point(i2)
    # print(points)
    # # print(point)
    im=cv2.imread(i1)
    for i in range(im.shape[0]):
        for j in range(im.shape[1]):
            if [i,j]  in points:
                im[i,j]=[255,0,255]
            else:
                im[i,j]=im[i,j]
    print(i3)
    cv2.imwrite(i3,im)

